#ifndef CHANNELS_H
#define CHANNELS_H

#include "RtDataChannel.h"

#include <QPointer>

/** A channel for time measurement.

  \ingroup RtCore

  Every time the channel is executed it registers the current time.

  Can be used as a timer.

*/
class RTLAB_BASE_EXPORT RtTimeChannel : public RtDataChannel
{
	Q_OBJECT
protected:
	virtual void run();
public:
	Q_INVOKABLE
	RtTimeChannel(const QString& name);
	virtual ~RtTimeChannel(void);
};

/** A channel for testing.

  \ingroup RtCore

  The test channel generates data according to the TestType and parameter chosen.
  The data can be random noise, a continously increasing/decreasing value, or a sine wave.

*/
class RTLAB_BASE_EXPORT RtTestChannel : public RtDataChannel
{
	Q_OBJECT

	/// Set the test type.
	Q_PROPERTY(TestType type READ type WRITE setType)
	/** A parameter with different meaning according to type of test.
	  For random noise it is the amplitude.
	  For inc/dec it is the increment/decrement.
	  For sine wave it is the frequency.
	  */
	Q_PROPERTY(double par READ par WRITE setPar)

	Q_ENUMS(TestType)

public:
	enum TestType { Random, Inc, Dec, Sin };

protected:
	TestType type_;
	double par_;
	double v;

	virtual void run();

public:
	Q_INVOKABLE
	RtTestChannel(const QString& name);
	virtual ~RtTestChannel(void);

	virtual void registerTypes(QScriptEngine *e);

	TestType type() const { return type_; }
	void setType(TestType type) { type_ = type; v = 0; }
	double par() const { return par_; }
	void setPar(double v) { par_ = v; }
};

/** A channel for filtering another channel's data.

  \ingroup RtCore

  Performs filtering operations on data from the specified inputChannel.

  If the filter channel is the child of another data channel, then automatically
  it takes input from its parent (unless another inputChannel is specified).

*/
class RTLAB_BASE_EXPORT RtFilterChannel : public RtDataChannel
{
	Q_OBJECT


	/** The input channel to filter.
	  */
	Q_PROPERTY(RtObject* inputChannel READ inputChannel WRITE setInputChannel)

protected:
	QPointer<RtDataChannel> inputChannel_;

	virtual void run();

public:
	RtFilterChannel(const QString& name);

	void setInputChannel(RtObject* obj);
	RtObject* inputChannel();

};

#endif // CHANNELS_H
